<?php
namespace app\api\controller;
use app\api\controller\Base;
use think\Db;
class Index extends Base
{
	public function _empty()
    {
        header("Location:/404.html"); 
        exit;
    }
   public function index()
   {
   	header('Access-Control-Allow-Origin:*'); //用于跨域
	$data=input('param.');
	
	if(!isset($data['type'])){
		return ['code'=>0,'message'=>'非法获取'];
	}

	if($data['type']=='denglu'){	
		$res=Db::name('admin')->where('username',$data['username'])->where('pass',$data['pass'])->find();
		if($res){
			return ['code'=>1,'message'=>'获取成功','data'=>['userid'=>$res['id'],'pass'=>md5($data['pass']),'name'=>$data['username']]];
		}else{
			return ['code'=>0,'message'=>'获取错误'];
		}
	}
	if($data['type']=='getlist'){	
		$on_arr=json_decode($data['on_arr'],true);
		$res=Db::name('admin')->where('id','in',$on_arr)->select();
		if($res){
			return ['code'=>1,'message'=>'获取成功','data'=>$res];
		}else{
			return ['code'=>0,'message'=>'获取错误'];
		}
	}
	



return ['code'=>0,'message'=>'非法获取'];
   
   
   
	}
}